package com.ordos.recruit.module.dict.controller;

import com.ordos.recruit.module.dict.entity.DictionaryItemDto;
import com.ordos.recruit.module.dict.entity.DictionaryItemPo;
import com.ordos.recruit.module.dict.service.DictService;
import com.wonders.commons.util.response.ApiResponse;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 字典 Controller
 *
 * @author jin
 */
@RequestMapping("dict")
@RestController
public class DictController {

    private final DictService dictService;

    public DictController(DictService dictService) {
        this.dictService = dictService;
    }

    @PostMapping("getDetailByCode")
    public ApiResponse<DictionaryItemPo> getDetailByCode(@RequestBody DictionaryItemDto dictionaryItemDto) {

        return ApiResponse.success(dictService.getDictByCode(dictionaryItemDto));

    }

    /**
     * 获取列表。
     *
     * @return ApiResponse
     */
    @PostMapping("getList")
    public ApiResponse<List<DictionaryItemPo>> getList(@RequestBody DictionaryItemDto dictionaryItemDto) {

        return ApiResponse.success(dictService.getDictByDid(dictionaryItemDto.getCodeType()));

    }

}
